const Koa = require('koa');
const router = require('koa-router')();
const app = new Koa();

var a = function () {
    return new Promise(function (reslove) {
        setTimeout(() => {
            reslove('大家好2');
        }, 2000);
    })
}


router.get('/demo', async (ctx, next) => {
    ctx.res.writeHead(200 , {'Content-Type': 'text/html;charset=utf-8'});
    ctx.res.write('大家好1');
    // setTimeout(() => {
    var html2 = await a();
    ctx.res.write(html2);
    ctx.res.end();
    // },200);
})

app.use(router.routes());

app.listen(3000);